<template>
    <div class="sub-layout resource-content">
        <div class="sub-sidebar">
            <div class="search-bar">
                <!-- <button @click="addResource">添加</button> -->
                <div class="search-box"></div>
                <a class="add" @click="addResource">
                    <i class="icon i-plus"></i>
                </a>
            </div>
            <div class="side-nav">
                <el-tree node-key="deptCode" :data="allResource" :props="defaultProps" @node-click="nodeClick"></el-tree>
            </div>
        </div>
        <div class="sub-main">
            <div class="content">
                <div class="section section-panel">
                    <div class="panel-title">
                        <span class="title">资源定义</span>
                        <div class="title-right">
                            <button class="btn-child" @click="addChildResource">添加子资源</button>
                        </div>
                    </div>
                    <div class="panel-content">
                        <div class="form-box">
                            <el-form :ref="form.ref" :rules="form.rules" :model="formData">
                                <el-form-item v-if="parentName" label="父级">
                                    <el-input disabled type="text" v-model="parentName"></el-input>
                                </el-form-item>
                                <el-form-item label="名称" prop="name">
                                    <el-input type="text" v-model="formData.name"></el-input>
                                </el-form-item>
                                <el-form-item label="URL地址" prop="url">
                                    <el-input type="text" v-model="formData.url"></el-input>
                                </el-form-item>
                                <el-form-item label="路由地址" prop="router">
                                    <el-input type="text" v-model="formData.router"></el-input>
                                </el-form-item>
                                <el-form-item label="图标" prop="icon">
                                    <el-input type="text" v-model="formData.icon"></el-input>
                                </el-form-item>
                                <el-form-item label="类型">
                                    <el-radio-group v-model="formData.type">
                                        <el-radio label="0">目录</el-radio>
                                        <el-radio label="1">菜单</el-radio>
                                        <el-radio label="2">按钮</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="权限标注" prop="permissionKey">
                                    <el-input type="text" v-model="formData.permissionKey" placeholder="如:user:queryDept , 多个请用 “,” 隔开"></el-input>
                                </el-form-item>
                            </el-form>
                            <div class="form-btn">
                                <button @click.prevent="sumbitForm">保存</button>
                                <button class="btn-delete" @click="deleteResource">删除</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import resourceMixin from './resource';
    export default {
        name: 'resource',
        mixins: [resourceMixin]
    }
</script>